package 搜索算法.广度优先搜索;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@SuppressWarnings("all")
public class DFS {
    public static void main(String[] args) {
        System.out.println(3 % 7);
    }

    // 组合字符
    public static void combine(char[] chars) {
        List<List<Character>> ans = new ArrayList<>();
        List<Character> res = new ArrayList<>();
        boolean[] visited = new boolean[chars.length];
        Arrays.fill(visited,false);
        dfs(chars,visited,res,ans);
    }

    public static void dfs(char[] chars,boolean[] visited,List<Character> res,List<List<Character>> ans) {
        if (res.size() == chars.length) {
            for (Character re : res) {
                System.out.print(re+" ");
            }
            System.out.println();
            return;
        }
        for (int i = 0; i < chars.length; i++) {
            // 判断当前字符是否被访问
            if (visited[i] == false) {
                visited[i] = true; // 修改当前访问元素的状态
                res.add(chars[i]); // 添加到res中
                dfs(chars,visited,res,ans);
                res.remove(res.size()-1);
                visited[i] = false;
            }
        }
    }
}
